<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>新闻管理系统</title>
	<style type="text/css">
		table{
			font-family:微软雅黑;

		}
		h3{
			font-family:微软雅黑;
		}

	</style>
</head>
<body>
	<center>
		<?php include('menu.php');//导入导航栏?>

		<h3>浏览新闻</h3>

		<table border='1' width='880'>
			<tr>
				<th>新闻ID</th><th>新闻标题</th><th>新闻关键字</th><th>作者</th><th>发布时间</th><th>新闻内容</th><th>操作</th>
			</tr>
			<?php 
				//1.导入数据库配置
				require('config.php');

				//2.链接数据库,选择数据库
				$link = @mysql_connect(HOST,USER,PWD) or die('链接数据库失败!');
				mysql_select_db(DBNAME);
				mysql_set_charset(UTF);

				//3.准备sql语句 执行sql语句
				$sql ='select * from news order by id';
				//echo $sql;die;

				$result = mysql_query($sql);

				if(mysql_num_rows($result)>0){

					while ($row = mysql_fetch_assoc($result)) {

						///var_dump($row);die;
					
						echo "<tr>";
							echo "<td>{$row['id']}</td>";
							echo "<td>{$row['title']}</td>";
							echo "<td>{$row['keywords']}</td>";
							echo "<td>{$row['author']}</td>";
							echo "<td>".date('Y-m-d',$row['addtime'])."</td>";
							echo "<td>{$row['content']}</td>";
							echo "<td><a href='action.php?action=del&id={$row['id']}'>删除</a>
								<a href='./edit.php?action=update&id={$row['id']}'>修改</a>
								</td>";
						echo "</tr>";
					}

				}

				//4.关闭数据库
				mysql_close();

			 ?>

			
			

		</table>
		
	</center>	
</body>
</html>